package com.ysactive.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * Notice:
 *
 * @author xuxu
 * @version 1.0
 * @date 2023/7/15
 * @since 1.0
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class BaseResponse<T> implements Serializable {
    private String code;
    private String msg;
    private T data;

//    public BaseResponse(String code,String msg){
//        this.setMsg(msg);
//        this.setCode(code);
//        this.setData(null);
//    }
//
    public static <T> BaseResponse<T> success(T data) {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setMsg("SUCCESS!!!");
        baseResponse.setCode("000");
        baseResponse.setData(data);
        return baseResponse;
    }

    public static <T> BaseResponse<T> fail(String msg) {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setMsg(msg);
        baseResponse.setCode("999");
        baseResponse.setData(null);
        return baseResponse;
    }

}
